package cz.cernilovsky.android.profileapp.model;

import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.hardware.SensorManager;

public class BluetoothAction extends Action {

	public BluetoothAction(Operation typeOfAction) {
		super(typeOfAction);
	}

	@Override
	public boolean perform(Context context) {
		if(operation != Operation.NOOP) {
			BluetoothAdapter ba = BluetoothAdapter.getDefaultAdapter();
			if((ba.isEnabled() && operation == Operation.OFF) || (!ba.isEnabled() && operation == Operation.ON)) {
				switch(operation) {
				case ON:
					ba.enable();
					break;
				case OFF:
					ba.disable();
					break;
				}
				return true;
			}
		}
		return false;
	}

}
